<html>
<head><meta charset="utf-8"><title>Package [lib] &amp; [bin] inside workspace · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Package.20.5Blib.5D.20.26.20.5Bbin.5D.20inside.20workspace.html">Package [lib] &amp; [bin] inside workspace</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="226959450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Package%20%5Blib%5D%20%26%20%5Bbin%5D%20inside%20workspace/near/226959450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CPerezz <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Package.20.5Blib.5D.20.26.20.5Bbin.5D.20inside.20workspace.html#226959450">(Feb 19 2021 at 12:58)</a>:</h4>
<p>Hi.<br>
I'm looking at the docs, and I try to find something that helps me to debug or clarify the situation I'm in now.<br>
As <code>workspace</code> docs say, you can have any package as member. Therefore, I have among others, a package as member that contains on it's <code>Cargo.toml</code> the following:</p>
<div class="codehilite" data-code-language="TOML"><pre><span></span><code><span class="k">[package]</span>
<span class="n">name</span> <span class="o">=</span> <span class="s">"XXX"</span>
<span class="n">version</span> <span class="o">=</span> <span class="s">"0.1.0"</span>
<span class="n">authors</span> <span class="o">=</span> <span class="p">[</span>
  <span class="s">"CPerezz &lt;mail&gt;"</span><span class="p">,</span>
<span class="p">]</span>
<span class="n">edition</span> <span class="o">=</span> <span class="s">"2018"</span>
<span class="n">autobins</span> <span class="o">=</span> <span class="kc">false</span>

<span class="k">[lib]</span>
<span class="n">name</span> <span class="o">=</span> <span class="s">"XXX"</span>
<span class="n">path</span> <span class="o">=</span> <span class="s">"lib/lib.rs"</span>

<span class="k">[[bin]]</span>
<span class="n">name</span> <span class="o">=</span> <span class="s">"XXX"</span>
<span class="n">path</span> <span class="o">=</span> <span class="s">"bin/main.rs"</span>
</code></pre></div>
<p>The package has the same name as the lib and the bin. At the same time, I have XXX as a member on the workspace. <br>
And finally the dir structure looks like:</p>
<div class="codehilite"><pre><span></span><code>|
|-- Cargo.toml (workspace one which XXX included)
|-- XXX/
     |-- Cargo.toml (contains the manifest posted above)
     |-- src/
           |-- lib/lib.rs
           |-- bin/bin.rs
</code></pre></div>
<p>I assume is not a naming problem since this worked when I didn't have the workspace. But as soon as I added it, it started failing on te build saying:<br>
<code> couldn't read XXX/lib/lib.rs: No such file or directory (os error 2)</code> which I found really weird. </p>
<p>Are there any known limitations for workspaces in these kind of situations?? Thanks</p>



<a name="226959709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Package%20%5Blib%5D%20%26%20%5Bbin%5D%20inside%20workspace/near/226959709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Package.20.5Blib.5D.20.26.20.5Bbin.5D.20inside.20workspace.html#226959709">(Feb 19 2021 at 13:01)</a>:</h4>
<p>For <code>lib.rs</code> and <code>main.rs</code> you have to specify the paths relative to the Cargo.toml directory. So adding <code>src/</code> in front of the paths in the <code>Cargo.toml</code> should fix this.</p>



<a name="226960266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Package%20%5Blib%5D%20%26%20%5Bbin%5D%20inside%20workspace/near/226960266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> CPerezz <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Package.20.5Blib.5D.20.26.20.5Bbin.5D.20inside.20workspace.html#226960266">(Feb 19 2021 at 13:06)</a>:</h4>
<p>I'm so stupid.. <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> <br>
Thanks a lot for your time!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>